package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingGradeDto;
import com.zzyl.service.NursingGradeService;
import com.zzyl.vo.NursingGradeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Api(tags = "护理等级")
@RequestMapping("/nursingLevel")
public class NursingGradeConteller extends BaseController{
    @Autowired
    private NursingGradeService nursingGradeService;

    /**
     * 查询所有护理等级
     * @return
     */
    @ApiOperation("查询所有护理等级")
    @GetMapping("/listAll")
    public ResponseResult<List<NursingGradeVo>> list(){
        List<NursingGradeVo>list = nursingGradeService.findAll();
        return success(list);
    }

    /**
     *条件分页查询护理等级
     */
    @ApiOperation("分页查询护理等级")
    @GetMapping("/listByPage")
    public ResponseResult<PageResponse<NursingGradeVo>> selectPage(@ApiParam(value = "护理项目名称") String name,
                                                                   @ApiParam(value = "护理项目状态") Integer status,
                                                                   @ApiParam(value = "分页页码")@RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum,
                                                                   @ApiParam(value = "每页大小")@RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize){
        PageResponse<NursingGradeVo> pageResponse = nursingGradeService.selectPage(name,status,pageNum,pageSize);
        return success(pageResponse);
    }

    /**
     * 新增护理等级
     */
    @ApiOperation("新增护理等级")
    @PostMapping("/insert")
    public ResponseResult add(@ApiParam(value = "护理项目传输对象",required = true)
                              @RequestBody NursingGradeDto nursingGradeDto){
        nursingGradeService.add(nursingGradeDto);
        return success();
    }
}
